<template>
  <div>
    <test-child @child-click="getChildMethod" ref="child"></test-child>
  </div>
</template>

<script lang="ts">
/* eslint-disable */
import { defineComponent, ref } from "vue";
import testChild from "./child.vue";

export default defineComponent({
  name: "test-father",
  components: {
    testChild
  },
  setup() {
    const child = ref(null);
    function getChildMethod(childValue: number) {
      console.log("Get message from child：" + childValue);
      /**
       * 直接获取子组件实例
       */
      console.log((child.value as any).add);
    }

    
    return {
      child, getChildMethod
    };
  }
});
</script>

<style></style>
